package com.cytech.cloudclinic.moudle.main.patient.detail.caseinfo;

import com.cytech.cloudclinic.base.BaseBean;
import com.cytech.cloudclinic.base.BaseObserver;
import com.cytech.cloudclinic.base.BasePresenter;
import com.cytech.cloudclinic.base.BaseView;
import com.cytech.cloudclinic.bean.CaseInfo;
import com.cytech.cloudclinic.bean.Patient;
import com.cytech.cloudclinic.bean.req.BasePage;
import com.yechaoa.yutils.ToastUtil;
import com.cytech.cloudclinic.bean.resp.RespCaseInfoList;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class PatientDetailCasePresenter extends BasePresenter<PatientDetailCaseView>{
    public PatientDetailCasePresenter(PatientDetailCaseView baseView) {
        super(baseView);
    }

    /**
     * 患者详情案例信息
     */
    void getPatientCase(int parent_id) {
        JSONObject json = new JSONObject();
        try {
            json.put("page",1);
            json.put("count",1000);
            json.put("patient_id",parent_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        String requestStr = json.toString();
        RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestStr);
        addDisposable(apiServer.getPatientDetailCase(body), new BaseObserver<BaseBean<RespCaseInfoList>>(baseView, false) {

            @Override
            public void onSuccess(BaseBean<RespCaseInfoList> o) {
                baseView.getPatientCaseListSuccess(o.result.data);
            }

            @Override
            public void onError(String msg) {
                ToastUtil.showToast(msg);
            }
        });
    }
}
